package cn.acewill.yxd.yunxundian.adapter;

import android.content.ContentValues;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.acewill.yxd.yunxundian.R;
import cn.acewill.yxd.yunxundian.model.TaskBean;

/**
 * Created by AAA on 2017/4/7.
 */

public class TaskAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<TaskBean> list;

     public TaskAdapter (Context context, ArrayList<TaskBean> list){
        this.context=context;
         this.list=list;
    }
    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.sign_task,parent,false);
            holder=new ViewHolder();
            holder.TaskTitle= (TextView) convertView.findViewById(R.id.TaskTitle);
            holder.taskStartTime= (TextView) convertView.findViewById(R.id.taskStartTime);
            holder.taskEndTime= (TextView) convertView.findViewById(R.id.taskEndTime);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        TaskBean bean=list.get(position);
        holder.TaskTitle.setText(bean.getTaskName());
        holder.taskStartTime.setText(bean.getTaskStartTime());
        holder.taskEndTime.setText(bean.getTaskEndTime());

        return convertView;
    }
    class ViewHolder{
        TextView TaskTitle;
        TextView taskStartTime;
        TextView taskEndTime;
    }
}
